<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>详情页</title>
    <link rel="stylesheet" href="../css/qt/nav.css">
    <link rel="stylesheet" href="../css/qt/list.css">
    <link rel="stylesheet" href="../css/qt/show.css">
    <script src="../JS/jquery-1.12.4.js"></script>
    <script src="../JS/screen.js"></script>

</head>
<body>
<!--   弹幕框starting     -->
<div class="screen-frame" id="screen-frame"></div>
<!--   弹幕框ending     -->
<!--  导航starting   -->
<?php
require ('../qt/common/list_nav.php');
?>
<!--  导航ending   -->
<!-- 详情内容starting  -->
<div class="show_main">
    <!-- MySQL操作 starting  -->
<?php
require ('../ht/Common/db.php');
//连接数据库
session_start();
//类型id是通过GET方法提交的
//根据类型vid从数据库中查询某个特定视频信息
$bid = $_GET['bid'];
$sql="select * from blogs where bid=$bid";
//echo $sql;
$result = mysql_query($sql) or die('查询1失败！'.mysql_error());
$row = mysql_fetch_assoc($result);
//取得留言分页记录
//获取指定的页码
//判断是否指定第几页，如果没有指定，则显示第1页。
if(!isset($_GET["page"]))
    $page=1;
else{
    $page=$_GET["page"];
}
//获取总行数，用于计算分几页显示
$sql0="select * from comments where bid=$bid";
$result0 = mysql_query($sql0);
$totalrows = mysql_num_rows($result0);
//定义每页显示的行数
$rowsperpage =5;
//计算从表中第几行开始输出
$start = ($page-1) * $rowsperpage;
//查询用户，从第$start行开始，共查询$rowsperpage行。
$sql0.= " limit {$start}, {$rowsperpage}";
// echo $sql0.'<br/>';
//执行sql语句
$result0= mysql_query($sql0) or die('查询2失败！'.mysql_error());
//更新游览量
$visit=$row["visited"]+1;
$sql2="update blogs set visited=$visit where bid=$bid";
mysql_query($sql2) or die('查询3失败！'.mysql_error());
?>
    <!--  MySQL操作 ending  -->
    <div class="show_content ">
        <h3> <?php echo $row['title']; ?></h3>
      <div class="show_note clearfix">
          <ul class="detail">
              <li>
                  <img src="../images/Font_Icon/心.png" alt="收藏量" title="收藏量">
                  <span><?php
                      echo $row["like"];
                      ?></span>
              </li>
              <li>
                  <img src="../images/Font_Icon/眼睛.png" alt="游览量" title="游览量">
                  <span><?php
                      echo $row["visited"];
                      ?>1111</span>
              </li>
              <li>
                  <img src="../images/Font_Icon/时钟.png" alt="上传时间" title="上传时间">
                  <span><?php
                      echo $row["uploaddate"];
                      ?></span>
              </li>
              <li>
                  <img src="../images/Font_Icon/沐歌.png"  alt="上传人" title="上传人">
                  <span><?php
                      echo $row["uploadadmin"];
                      ?></span>
              </li>
          </ul>
      </div>
        <img src="../images/blog/JavaScript算法1.png" alt="JavaScript算法1" title="JavaScript算法1" width="1080px">
        <img src="../images/blog/JavaScript算法2.png" alt="JavaScript算法2" title="JavaScript算法2" width="1080px">

        <div class="show_video">
            <iframe src="//player.bilibili.com/player.html?aid=69856262&cid=121039830&page=1"
                    scrolling="no" border="0" frameborder="no"
                    framespacing="0" allowfullscreen="true" autoPlay=false width="1080px" height="800px" > </iframe>
        </div>
<!--    弹幕starting    -->
        <div class="bullet_screen">
            <div class="content">
                <p class="title">全屏弹幕:</p>
                <input type="text" class="text" id="text"/>
                <button type="button" class="btn" id="btn">发射</button>
            </div>
        </div>
<!--   弹幕ending     -->
<!--  如果有留言则显示留言列表    -->
        <?php
        $num=mysql_num_rows($result0);
        if ($num>0){
        ?>
        <h2 class="message">留言列表</h2>
        <!-- 留言和评分starting   -->
        <table class="gridtable" >
            <tr>
                <th>序号</th>
                <th>内容</th>
                <th>评论人</th>
                <th>发表时间</th>
            </tr>
            <?php
            $i=1;
            while ($row=mysql_fetch_assoc($result0)){
            ?>
            <tr>
                <td><?php
                    echo $i++;
                    ?></td>
                <td><?php
                    echo $row["content"];
                    ?></td>
                <td><?php
                    $uid=$row["uid"];
                    $userrs=mysql_query("select *from users where uid=$uid");
                    $user=mysql_fetch_assoc($userrs);
                    echo $user["uname"];
                    ?></td>
                <td><?php
                    echo $row["cdate"];
                    ?></td>
            </tr>
            <?php
            }
            ?>
        </table>
        <?php
         }
         else{
             ?>
        <div class="empty_message message">
            <h2>暂无留言</h2>
        </div>
        <?php
         }
       ?>

<!-- 留言和评分 starting    -->
        <?php
        session_start();
        if(isset($_SESSION["user"]))
        {
            ?>
            <!--    显示留言ending     -->
            <!--评分starting-->
            <form action="doAssess.php" method="post" >
                <input type="hidden" name="bid" value="<?php echo $bid?>">
                <div class="assess" >
                    <ul class="ass_comment" >
                        <li>☆</li>
                        <li>☆</li>
                        <li>☆</li>
                        <li>☆</li>
                        <li>☆</li>
                    </ul>
                    <input type="hidden" name="evaluate" class="eval">
                    <input class="subAssess" type="submit" value="发表评价">
                </div>
                <script src="../JS/star.js"></script>
            </form>
            <!--评分ending-->
       <div >
           <form method="post" action="doComment.php" >
               <input type="hidden" name="bid" value="<?php echo $bid?>">
               <textarea class="showComment" required="required" name="content"></textarea>
               <div class="sumComment">
               <input type="submit"  value="发表留言">
               </div>
           </form>

       </div>
        <?php
}else{
    ?>
        <div class="empty_login">
      <h2>请您<a href="qt_login/qt_login.php">登录</a>,才能对博文评价和留言哦~</h2>
        </div>
        <?php
        }
        ?>
<!--    留言ending    -->
</div>
</div>
<!--  详情内容ending   -->
</body>
</html>